<?php include "config.php" ?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Nusantara View</title>
<!-- #BeginLibraryItem "/Library/jquey.lbi" --><script type="text/javascript" src="hebergement_files/jquery.js"></script>
<script type="text/javascript" src="hebergement_files/thickbox.js"></script>
<link rel="stylesheet" type="text/css" href="hebergement_files/thickbox.css" media="screen"><!-- #EndLibraryItem -->
<?php 

function translateLatLngtoAddress($lat,$long,$key)
    {
    $lat=mb_convert_encoding($lat, 'UTF-8',mb_detect_encoding($lat, 'UTF-8, ISO-8859-1', true));
    $long=mb_convert_encoding($long, 'UTF-8',mb_detect_encoding($long, 'UTF-8, ISO-8859-1', true));

    $url="http://maps.google.com/maps/geo?q=$lat,$long&output=csv&sensor=false&key=".$key;
    $response = getGeolocation($url);

    if (substr($response, 0, 3) === '200') {
    return $geo = explode(',', $response);
    }
    return false;
    }
	
	function getGeolocation($url)
    {

    $init = curl_init();
    curl_setopt($init, CURLOPT_URL, $url);
    curl_setopt($init, CURLOPT_HEADER,0);
    curl_setopt($init, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
    curl_setopt($init, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($init);
    curl_close($init);
    return $response;
    }
?>	

<script
src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAlSrsSTN5DgS8ZVvOIMXgaRTNmsdf8oJErPgj8pmeVh4CV1HAChSnA5L1BrGdSJY6TQbpy9Y0lCCvvg"></script>

<script type="text/javascript">
var map;
var geoXml;

function initialize() {
      
      if (GBrowserIsCompatible()) {      
        geoXml = new GGeoXml("http://nusantaraview.web.id/transport/hasil.php");
		
		map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(-7.2491667, 112.7508333), 17);
        map.setUIToDefault();;

        map.addOverlay(geoXml);
		
      }
    }

</script>

</head>

<body onload="initialize()" onunload="GUnload()">
<div id="top"> 
    
   
  <div id="main"> 
    <div id="content-hebergement" class="content">
      <div id="page"> 
        <table width="200" border="1">
          <tr>
            <td> <? $result = mysql_query("SELECT transport.Nama as Nama, jalur.lng as lng, jalur.lat as lat FROM jalur inner join transport on jalur.idt = transport.ID where jalur.status != 0");
  while($r = mysql_fetch_array($result)) 
   { 
   	$nama = $r[Nama];
	$latitude=$r[lat];
    $longitude=$r[lng];
	
		$key= "ABQIAAAAlSrsSTN5DgS8ZVvOIMXgaRRko6GAsd-NuNaX8qRhTW-5iKUrrhQAEyRuTDiP8alMZuDudl0V6ctgMw";
	$data=translateLatLngtoAddress($latitude,$longitude,$key);
	if ($nilai != $data [2]) {
    echo "<pre>";
	echo "Gunakan ".$nama." di".$data [2].",".$data[3];
    echo "</pre>";
	$nilai = $data [2];
	}

 } ?></td>
            <td><div id="map_canvas" style="width: 800px; height: 800px"></div></td>
          </tr>
        </table>
		<form action="latlng.php" method="post" >
        <table width="836" bordercolor="#ECE9D8">
          <tr>
            <th width="115" align="right"><div align="left" class="style1">Posisi Anda Sekarang </div></th>
            <td width="300"><label>
                <div align="left">
                  <input name="from" type="text" size="50" />
                  Masukkan nama jalan, nama kecamatan,  nama kota (contoh : Jalan Bubutan, Bubutan, Surabaya)
                  </label>
              </div></td>
            <td width="268"><div align="left" class="style1">Tujuan :</div></td>
            <td width="133"><select name="to">
                <? $result = mysql_query("SELECT * FROM jos_nusaview order by name");
  while($r = mysql_fetch_array($result)) 
   { 
    echo "<option value='$r[latitude],$r[longitude]'>$r[name]</option>";
	
	

 } ?>
              </select>
            </td>
          </tr>
          <tr>
            <th>&nbsp;</th>
            <td colspan="7"><div align="left">
                <input name="submit" type="submit" value="Cari Rute" />
            </div></td>
          </tr>
        </table>
		</form>
        <p>&nbsp;</p>
        <p>
        
        </p>
</div>
    </div>
  </div>
  <div id="footer"></div>
</div>
<!-- #BeginLibraryItem "/Library/google-analytics.lbi" --><script src="hebergement_files/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-2218183-1";
urchinTracker();
</script><!-- #EndLibraryItem -->
</body>
</html>
